/**
 * @file 用户model
 * @author wangshaozhi(wangshaozhi@baidu.com)
 */

import {action, makeObservable, observable} from "mobx";

class User implements User.IUserProps {
    id: string = '';
    username: string = '';
    password: string = '';
    avatarUrl: string = '';
    motto: string = '';


    constructor(props: Partial<User.IUserProps>) {
        makeObservable(this, {
            id: observable,
            username: observable,
            password: observable,
            avatarUrl: observable,
            motto: observable
        });
        this.update(props);
    }

    update = action((data: Partial<User.IUserProps>) => {
        Object.assign(this, data);
    })
}

namespace User {
    export interface IUserProps {
        /** 用户id */
        id: string;
        /** 用户名 */
        username: string;
        /** 用户密码 */
        password: string;
        /** 头像地址 */
        avatarUrl: string;
        /** 座右铭 */
        motto: string;
    }
}

export default User;